// MIT License
// 开源地址：https://gitee.com/co1024/AbcMvc
// Copyright (c) 2021-2023 1024
// Abc.Mvc=Furion+EF+SqlSugar+Pear layui admin.

namespace Abc.Application.HtAdminServices;

/// <summary>
/// ServiceMapper
/// </summary>
public class HtUserOutMapper : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        // 示例
        //config.ForType<__EFMigrationsHistory,__EFMigrationsHistoryDto>()
        //.Map(dest => dest.MigrationId, src => src.MigrationId)//
        //.Map(dest => dest.ProductVersion, src => src.ProductVersion)//
        //;

        // Description 用户表
        config.ForType<SysUser, HtUserOut>()
            .Map(dest => dest.Roles, src => src.Roles)
            .Map(dest => dest.RoleName, src => src.Roles != null ? string.Join(',', src.Roles.Select(r => "," + r.Name ?? "")).Trim(',') : "")
      //.Map(dest => dest.Id, src => src.Id)// ID
      //.Map(dest => dest.Account, src => src.Account)// 用户名
      //.Map(dest => dest.Pwd, src => src.Pwd)// 密码
      //.Map(dest => dest.UserType, src => src.UserType)// 账户类型
      //.Map(dest => dest.IsEnable, src => src.IsEnable)// 是否启用
      //.Map(dest => dest.IsEnableName, src => src.IsEnable?"是":"否")// 是否启用
      //.Map(dest => dest.IsTest, src => src.IsTest)// 是否测试
      //.Map(dest => dest.IsTestName, src => src.IsTest?"是":"否")// 是否测试
      //.Map(dest => dest.Nick, src => src.Nick)// 昵称
      //.Map(dest => dest.Email, src => src.Email)// 邮箱
      //.Map(dest => dest.Province, src => src.Province)// 省份
      //.Map(dest => dest.City, src => src.City)// 城市
      //.Map(dest => dest.Town, src => src.Town)// 镇
      //.Map(dest => dest.Address, src => src.Address)// 详细地址
      //.Map(dest => dest.Phone, src => src.Phone)// 联系电话
      //.Map(dest => dest.Tel, src => src.Tel)// 办公电话
      //.Map(dest => dest.Remark, src => src.Remark)// 备注
      .Map(dest => dest.LastLoginTime, src => src.LastLoginTime != null ? src.LastLoginTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")// 最后登录时间
                                                                                                                                       //.Map(dest => dest.LastLoginIp, src => src.LastLoginIp)// 最后登录IP
                                                                                                                                       //.Map(dest => dest.LastLoginUserAgent, src => src.LastLoginUserAgent)// 最后登录用户浏览器信息
                                                                                                                                       //.Map(dest => dest.CreatorUserId, src => src.CreatorUserId)// 创建用户ID
                                                                                                                                       //.Map(dest => dest.CreatorUserName, src => src.CreatorUserName)// 创建用户
      .Map(dest => dest.CreationTime, src => src.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"))// 创建时
                                                                                              //.Map(dest => dest.UpdateUserId, src => src.UpdateUserId)// 更新用户ID
                                                                                              //.Map(dest => dest.UpdateUserName, src => src.UpdateUserName)// 更新用户
      .Map(dest => dest.UpdateTime, src => src.UpdateTime != null ? src.UpdateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")// 更新时间
                                                                                                                              //.Map(dest => dest.IsDeleted, src => src.IsDeleted)// 默认假删除
                                                                                                                              //.Map(dest => dest.IsDeletedName, src => src.IsDeleted?"是":"否")// 默认假删除
                                                                                                                              //.Map(dest => dest.DeletedUserId, src => src.DeletedUserId)// 删除用户ID
                                                                                                                              //.Map(dest => dest.DeletedUserName, src => src.DeletedUserName)// 删除用户
      .Map(dest => dest.DeletedTime, src => src.DeletedTime != null ? src.DeletedTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")// 删除时间
      .Map(dest => dest.UserTypeName, src => src.UserType.ToString("G"))//用户类型
      ;
    }
}